package com.service.Impl;

import com.bean.Student;
import com.dao.StudentDao;
import com.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentDao studentDao;
    public List<Student> getStudents(){
        return studentDao.getStudents();
    }
    public List<Student> getStudentsByPage(int page,int limit){
        int start = (page-1)*limit;
        return studentDao.getStudentsByPage(start,limit);
    }
    public int getStudentsLength(){
        return studentDao.getStudentsLength();
    }

    public int addStudent(Student student){
        return studentDao.addStudent(student);
    }
    public int delStudentById(int id){ return studentDao.delStudentById(id); }
    public Student selectStudentById(int id){ return studentDao.selectStudentById(id); }
    public int updateStudentById(Student student){ return studentDao.updateStudentById(student); }

    @Override
    public List<Student> selectStudentByName(String name,int page, int limit) {
        int start = (page-1)*limit;
        return studentDao.selectStudentByName(name,start,limit);
    }

    @Override
    public int selectStudentByNameLength(String studentName) {
        return studentDao.selectStudentByNameLength(studentName);
    }

    @Override
    public List<Student> selectStudentBycId(int cid) {
        return studentDao.selectStudentBycId(cid);
    }

    @Override
    public int selectStudentBycIdLength(int cid) {
        return studentDao.selectStudentBycIdLength(cid);
    }

}
